﻿Imports System.Data.OleDb

Public Class Detail
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Response.Redirect("CarList.aspx?ID=" & Request.QueryString("ID"))
    End Sub

    Protected Sub btncomment_Click(sender As Object, e As EventArgs) Handles btncomment.Click

        If txtcomment.Text = "" Then
            MsgBox("ERROR please enter a comment!.")

        Else
            Dim sql As String = "INSERT INTO Image_Comment (CommentBody,DateUploaded,TimeUploaded,MemberIDFK,ImageIDFK) VALUES (@f1,@f2,@f3,@f4,@f5)"
            Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MercedesConnectionString").ConnectionString)
            Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

            cmd.Parameters.AddWithValue("@f1", txtcomment.Text)
            cmd.Parameters.AddWithValue("@f2", Now.Date.ToString("dd/MM/yyyy"))
            cmd.Parameters.AddWithValue("@f3", DateTime.Now.ToString("t"))
            cmd.Parameters.AddWithValue("@f4", Membership.GetUser(User.Identity.Name).ProviderUserKey)
            cmd.Parameters.AddWithValue("@f5", Request.QueryString("ID"))

            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
            cmd.Dispose()
            conn.Dispose()

            Response.Redirect("Detail.aspx?id=" & Request.QueryString("ID"))

        End If






    End Sub
End Class